package com.bw.a2207a.view

import android.os.Bundle
import android.widget.MediaController
import android.widget.VideoView
import androidx.appcompat.app.AppCompatActivity
import com.bw.a2207a.R

class VideoActivity : AppCompatActivity() {
    lateinit var videoView: VideoView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_video)

        videoView = findViewById<VideoView>(R.id.video)

        //设置视频播放地址
        videoView.setVideoPath("http://txmov2.a.yximgs.com/upic/2020/09/02/22/BMjAyMDA5MDIyMjAwNDZfNjU0Njc0XzM1NDM5MTg2Mjg3XzFfMw==_b_B3e4fad299fd832fc75ba67df44acb80b.mp4?tag=1-1599265874-vdg-1-r8rhfdew2y-62c7c39afc8eee5a&tt=b&bp=10000")

        //设置视频快进暂停 按钮
        videoView.setMediaController(MediaController(this))

        videoView.start()
//        videoView.setOnPreparedListener(object : OnPreparedListener {
//            override fun onPrepared(mp: MediaPlayer?) {
//                videoView.start()
//            }
//        })
    }

    override fun onDestroy() {
        super.onDestroy()
        videoView.stopPlayback()
    }
}